<script type="text/javascript">
    //add_to_cart
    function callback_add_to_cart(ec_data) {
    console.log('callback_add_to_cart');
    console.log(ec_data);
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_add_to_cart(ec_data);
    {% endif %}
    {%- if storeConfig.bing_uet_id -%}
    callback_bing_add_to_cart(ec_data);
    {% endif %}
    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_add_to_cart(ec_data);
    {% endif %}
    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_add_to_cart(ec_data);
    {% endif %}
    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_add_to_cart(ec_data);
    {% endif %}
    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_add_to_cart(ec_data);
    {% endif %}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_add_to_cart(ec_data);
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_add_to_cart(ec_data);
    {% endif %}

    callback_event_script_add_to_cart(ec_data);
    } catch (e) {
    console.log(e);
    }
    }

    //remove_from_cart
    function callback_remove_from_cart(ec_data) {
    console.log('callback_remove_from_cart');
    console.log(ec_data);
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_remove_from_cart(ec_data);
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_remove_from_cart(ec_data);
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_remove_from_cart(ec_data);
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_remove_from_cart(ec_data);
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_remove_from_cart(ec_data);
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_remove_from_cart(ec_data);
    {%- endif -%}
    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai__remove_from_cart(ec_data);
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_remove_from_cart(ec_data);
    {%- endif -%}
    callback_event_script_remove_from_cart(ec_data);
    } catch (e) {
    console.log(e);
    }
    }

    //登陆
    function callback_login() {
    console.log('callback_login');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_login();
    {%- endif -%}
    {%- if storeConfig.bing_uet_id -%}
    callback_bing_login();
    {%- endif -%}
    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_login();
    {%- endif -%}
    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_login();
    {%- endif -%}
    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_login();
    {%- endif -%}
    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_login();
    {%- endif -%}
    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_login();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_login();
    {%- endif -%}
    callback_script_event_login();
    } catch (e) {
    console.log(e);
    }
    }

    //注册
    function callback_sign_up() {
    console.log('callback_sign_up');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_sign_up();
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_sign_up();
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_sign_up();
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_sign_up();
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_sign_up();
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_sign_up();
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_sign_up();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_sign_up();
    {%- endif -%}

    callback_event_script_sign_up();
    } catch (e) {
    console.log(e);
    }
    }

    //商品分享
    function callback_share_product(ec_data, platform) {
    console.log('callback_share_product');
    console.log(ec_data);
    console.log(platform);
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_share_product(ec_data, platform);
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_share_product(ec_data, platform);
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_share_product(ec_data, platform);
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_share_product(ec_data, platform);
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_share_product(ec_data, platform);
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_share_product(ec_data, platform);
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_share_product(ec_data, platform);
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_share_product(ec_data, platform);
    {%- endif -%}

    callback_event_script_share_product(ec_data, platform);
    callback_base_share_product(ec_data, platform);
    } catch (e) {
    console.log(e);
    }
    }

    //创建新用户 订阅、注册、下单 所有有可能创建新用户的地方
    function callback_generate_lead() {
    console.log('callback_generate_lead');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_generate_lead();
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_generate_lead();
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_generate_lead();
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_generate_lead();
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_generate_lead();
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_generate_lead();
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_generate_lead();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_generate_lead();
    {%- endif -%}

    callback_event_script_generate_lead();
    } catch (e) {
    console.log(e);
    }
    }


    function callback_begin_checkout() {
    console.log('callback_begin_checkout');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_begin_checkout();
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_begin_checkout();
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_begin_checkout();
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_begin_checkout();
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_begin_checkout();
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_begin_checkout();
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_begin_checkout();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_begin_checkout();
    {%- endif -%}

    callback_event_script_begin_checkout();
    } catch (e) {
    console.log(e);
    }
    }

    function callback_add_address_information() {
    console.log('callback_add_address_information');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_add_address_information();
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_add_address_information();
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_add_address_information();
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_add_address_information();
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_add_address_information();
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_add_address_information();
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_add_address_information();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_add_address_information();
    {%- endif -%}

    callback_event_script_add_address_information();
    } catch (e) {
    console.log(e);
    }
    }

    function callback_add_shipping_information() {
    console.log('callback_add_shipping_information');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_add_shipping_information();
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_add_shipping_information();
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_add_shipping_information();
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_add_shipping_information();
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_add_shipping_information();
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_add_shipping_information();
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_add_shipping_information();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_add_shipping_information();
    {%- endif -%}

    callback_event_script_add_shipping_information();
    } catch (e) {
    console.log(e);
    }
    }

    function callback_add_payment_information() {
    console.log('callback_add_payment_information');
    try {
    {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
    {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
    {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
    {%- if adwords or tracking or conversion -%}
    callback_google_add_payment_information();
    {%- endif -%}

    {%- if storeConfig.bing_uet_id -%}
    callback_bing_add_payment_information();
    {%- endif -%}

    {%- assign facebook = storeConfig.facebook | strtoarray -%}
    {%- if facebook -%}
    callback_facebook_add_payment_information();
    {%- endif -%}

    {%- if storeConfig.pinterest_pixel_id -%}
    callback_pinterest_add_payment_information();
    {%- endif -%}

    {%- if storeConfig.snapchat_pixel_id|strtoarray -%}
    callback_snapchat_add_payment_information();
    {%- endif -%}

    {%- assign pixels = storeConfig.tiktok_pixel_id | strtoarray -%}
    {%- if pixels and storeConfig.tiktok_developer_mode -%}
    callback_tiktok_add_payment_information();
    {%- endif -%}

    {%- assign pixels = storeConfig.kwai_pixel_id | strtoarray -%}
    {%- if pixels -%}
    callback_kwai_add_payment_information();
    {% endif %}

    {%- if storeConfig.yahoo_pixel_id -%}
    callback_yahoo_add_payment_information();
    {%- endif -%}

    callback_event_script_add_payment_information();
    } catch (e) {
    console.log(e);
    }
    }

</script>

        {% include analysis_base %}

        {%- assign adwords = storeConfig.google_adwords_trace_id | strtoarray -%}
        {%- assign tracking = storeConfig.google_analytics_trace_id | strtoarray -%}
        {%- assign conversion = storeConfig.google_conversion_id | strtoarray -%}
        {%- if adwords or tracking or conversion -%}
        {% include analysis_google %}
        {%- endif -%}

        {%- if pixel_config.bing_pixel == true -%}
        {% include analysis_bing %}
        {%- endif -%}

        {%- if pixel_config.facebook_pixel == true -%}
        {% include analysis_facebook %}
        {%- endif -%}

        {%- if pixel_config.pinterest_pixel == true -%}
        {% include analysis_pinterest %}
        {%- endif -%}

        {%- if pixel_config.snapchat_pixel == true -%}
        {% include analysis_snapchat %}
        {%- endif -%}

        {%- if pixel_config.tiktok_pixel == true -%}
        {% include analysis_tiktok %}
        {%- endif -%}

        {%- if pixel_config.kwai_pixel_id == true -%}
        {% include analysis_kwai %}
        {%- endif -%}

        {%- if pixel_config.yahoo_pixel == true -%}
        {% include analysis_yahoo %}
        {%- endif -%}

        {% include analysis_event_script %}

        {% comment %}如果url有generate_lead参数  即代表有创建新用户{% endcomment %}
<script type="text/javascript">

{% if current_step == 'contact_information' and template == 'order_contact_information' %}
callback_begin_checkout();
{% endif %}

{% if current_step == 'shipping_method' and template == 'order_shipping_method' %}
callback_add_address_information();
{% endif %}

{% if current_step == 'payment_method' and template == 'order_payment_method' %}
callback_add_shipping_information();
{% endif %}

{% if current_step == 'payment_gateway' and template == 'order_payment_gateway' %}
// button event
// callback_add_payment_information();
{% endif %}

{% if request_param.generate_lead %}
callback_generate_lead();
{% endif %}
</script>